
$(document).ready(function(){
	$("<link rel='stylesheet' type='text/css' href='/img/jquery.ui.autocomplete.css' />").appendTo("head");
	
	var confs = [];
	$('input[name*="confName"]').autocomplete({"source" : confs, "minLength" : 2});
	$('input[name*="confName"]').after(" <span style='color:grey;font-size:small;font-style:italic;'></span>")
	
	$('input[name*="confName"]').live('keyup', function(){
		th = $(this);
		if (th.val().length > 2){
			$.ajax({'url' : '/indexer/getconference',
					'data' : {'conference' : $(this).val()},
					'dataType' : 'json',
					'success' : function(data){confs=eval(data)["names"];
											   if (data["count"] != data["names"].length){
											   	th.next().html("Zobrazeno prvních " + data["names"].length +" záznamů (celkem " + data["count"] + ")")
											   }
											   else{
											   	th.next().html("");
											   }
					},
					'async' : false,
					'type' : 'POST',
					});
		
			th.autocomplete({"source" : confs, "minLength" : 3});
		}
		else{
			th.next().html("");		
		}
		
	});
	
	

	
	
});
